﻿using System.Windows;
using Phoenix.ActionResults;
using Phoenix.Filters;
using Phoenix.Filters.ActionFilters;
using System.Net.NetworkInformation;

namespace HelloWorld.ActionFilters
{
    public class NetworkRequiredFilterAttribute : FilterAttribute, IActionFilter
    {
        public void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (!NetworkInterface.GetIsNetworkAvailable())
            {
                filterContext.Result = new MessageBoxActionResult(filterContext.ActionContext, "You need network access to do this, please try again",
                    "Network required", MessageBoxButton.OK);
            }
        }

        public void OnActionExecuted(ActionExecutedContext filterContext)
        {
            
        }
    }
}